package com.mlz.mlzmall.ui.utils.mlz;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Map;

/**
 * function:
 * Created by BINGO on 2016/2/27.
 * Package_Name:com.bin.news.ui.util.
 * Project_Name:news.
 */
public class ConfigInfo {
    public static String USERNAME = "userName";// 用户名
    public static String WELCOME="welcome";//SharedPreferences保存后的文件名
    public static String GUIDE="isGuide";
    public static String DB_NAME="mlz.db";
    public static String TOP_LEFT_BACK = "back";// 返回
    public static String TOP_LEFT_BACK_SETTING= "setting_back";// 个人中心
    public static String TYPE="Content-Type";//post请求头参数
    public static String TYPE_KEY="application/json";
    public static String COOKIE="Cookie";//post请求头参数
    public static String COOKIE_KEY="JSESSIONID=";
    public static String CHARSET="Charset";//post请求头参数
    public static String UTF8="UTF-8";
    public static String LOGIN_STATE="state";//记录登陆状态
    public static String SESSIONKEY="sessionKey";
    public static String SESSIONKEY_DATA="4302341A93D6DC03819DE0D5DDED1D6B";
    public static String PHONEID="phoneId";
    public static String DEVICEID="deviceId";
    public static final String APP_ID = "wxa73aa4da8c9efbf7";
    public static String ACT_STATUS="activity_status";
    public static int disPlay_W=0;
    public static int disPlay_H=0;
    public static int size=0;
    /**
     * 获取请求链接
     * @param url
     * @param paras
     * @return
     */
    public static String getUrl(String url, Map<String, String> paras)
    {

        StringBuilder sb = new StringBuilder(url);
        if (paras != null && !paras.isEmpty()) {
            sb.append("?");
            for (Map.Entry<String, String> entry : paras.entrySet()) {
                sb.append(entry.getKey()).append("=");
                try {

                    // MD5加密
                    //sb.append(URLEncoder.encode(MD5Utils.getMD5String(entry.getValue()), ConfigInfos.UTF8));//数据MD5加密
                    //不加密
                    sb.append(URLEncoder.encode(entry.getValue(), ConfigInfo.UTF8));//数据未加密
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                sb.append("&");
            }
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
}
